<!DOCTYPE HTML>
<html>
<head>
    <meta charset="UTF-8">
    
    <title>ERP-LOPS</title>
    <script>
    function getBrowserLabel(){
        var userAgent = window.navigator.userAgent||'';
        if(
            userAgent.replace(/cifangerppcapp/i,'')!=userAgent ||
            location.href.replace('cifangerppcapp','')!=location.href
        )return 'pcapp';
        return 'other'
    }
    var browserLabel = getBrowserLabel();
    
    var Init={
            clientBrowserLabel:browserLabel, 
            jsCorePath:'../JsCore/',
            erpAppPath: browserLabel==='pcapp'? 'http://hittime.net:8080/erp/Public/Erp/app/' :'app/',
            commGateway: browserLabel==='pcapp'? 'http://hittime.net:8080/erp/index.php' : '../../index.php',
            theme:'ext-theme-crisp',
            //theme:'ext-theme-crisp-touch',
            //theme:'ext-theme-neptune',
            sysType:'xmain',
            afterLoaded:function(){
                readyForApp();
                //Ext.get('page-loading').slideOut('b', { duration: 800 });
            },
            showLoginForm:function(fn){
                fn = fn||function(){};
                var el = Ext.fly('page-init-mask').applyStyles({
                    "backgroundColor":'#7bc5ff'
                }).highlight("fff",/*起始颜色*/
                    {
                        attr: 'backgroundColor', /*我们改变的是背景颜色*/  
                        duration: 2000,/*动画持续时间*/
                        endColor: "7bc5ff", /*结束颜色*/
                        easing: 'easeIn'
                    }
                );
                if(Init.isClient||false){
                    el.select('div.erp-login-cmd-row input.cancel').show();
                }else{
                    el.select('div.erp-login-cmd-row input.download').show();
                }
                //Ext.select('span.loginMessage').elements
                Ext.get('page-loading').slideOut('t', { duration: 800 ,callback:function(e){
                    Ext.get('page-loading').applyStyles({display:'none'});
                }});

                Ext.get('page-erp-login').slideIn('b', { duration: 800 });
                Fn.auth.checkLogin();                
            }
    };
    </script>
    <script src="start.js"></script>
    <style type="text/css">
    .main_center_handler{ -webkit-user-select:none; -webkit-app-region:drag;}
    .nw-app-drag{ -webkit-user-select:none; -webkit-app-region:drag; }
    #nw-window-headler{
        width:100%;
        z-index:2;    
        height:100%;
        overflow:hidden
    }
    .x-img,.x-window,.x-btn,.x-mask,.x-tool,.nw-app-nodrag{-webkit-app-region:no-drag;}
    @keyframes rotate{
        from {transform:rotate(0deg);}
        to {transform:rotate(360deg);}
    }
    @-moz-keyframes rotate,{
        from {-moz-transform:rotate(0deg);}
        to {-moz-transform:rotate(360deg);}
    }
    @-webkit-keyframes rotate {
        from {-webkit-transform:rotate(0deg);}
        to {-webkit-transform:rotate(360deg);}
    }
    
    div.mask-loading img{
      height: 128px;
      width: 128px;
            
      animation-name: rotate;
      animation-duration: 3s;
      animation-iteration-count: infinite;
      animation-timing-function: linear;

      -webkit-animation-name: rotate;
      -webkit-animation-duration: 3.5s;
      -webkit-animation-iteration-count: infinite;
      -webkit-animation-timing-function: linear;
    }

    .rcbody{overflow:hidden;}
    </style>    
</head>
<!--/*padding:1px;overflow: hidden;*/-->
<body class="rcbody"><!-#f5f5f5  background:#fff;-->
    <div id="page-init-mask" class="nw-app-drag loading" style="position:absolute; width:100%; height:100%;overfolw:hidden;overflow:hidden; background:#fff;z-index:10">
        <div id="page-loading" class="mask-loading" style="margin:auto;margin-top:100px;text-align:center;">
            <img src="app/includes/images/loading.jpg"><br>
            <div>正在加载...</div>
        </div>

        <div id="page-erp-login" class="erp-login" style="display:none">
        <div class="erp-login-main nw-app-nodrag">
            <form class="login-left" data-node="loginForm" onsubmit="return false;">
                <div style="color:#6C6B6B;"><h2 style="margin-top:0;">请先登录：</h2></div>
                <div class="erp-login-row erp-login-text-row">
                    <input type="text" placeholder="账号" name="account" class="login-username text">
                </div>
                <div class="erp-login-row erp-login-text-row">
                    <input type="password" placeholder="密码" name="password" class="login-password text">
                </div>
                <div class="erp-login-row erp-login-cmd-row">
                    <div class="loginMessage" style="float:left; color:red;"></div> 
                    <div>
                        <input type="button" value="" class="btn download" _sign="download" style="float:left;display:none; clear:both;">
                        <input type="button" value="" class="btn cancel" _sign="cancel" style="float:left;display:none">
                        <input type="submit" value="" class="btn submit" style="float:right;">
                    </div>
                </div>
            </form>
        </div>
        </div>
    </div>

    
    <script>
        function readyForApp(){
            if(!(Fn||false))Fn = {};
            Fn.url=function(p){

                var pathInfoSpr = '-';
                var tmp = (p+'?').split('?');
                var tmpArr = tmp[0].split('/');
                var queryStr = (tmp[1]||false)? '&'+tmp[1]: '';
                if(tmpArr.length=2){
                    p = 'Erp/'+tmp[0];//+queryStr;
                }
                if(pathInfoSpr!=='/')p = p.replace(/\//g,pathInfoSpr);
                //return 'http://127.0.0.1/erp/index.php?s='+p+queryStr;
                return (Init.commGateway||'')+'?s='+p+queryStr;
            };
            Fn.src.path=function(p){return (Init.erpAppPath+'/includes/images/').replace('//','/')+p;};
            
            Fn.app = Fn.app ||{};
            Fn.app.afterLoaded=function(){
                Ext.get('page-init-mask').setWidth(200, true).slideOut('r',{});
            }
            Fn.auth={
                check:function(sign){
                    return (Init.auth.check(sign)||false);
                },
                process:function(data,by,pfun,ok,no){
                    pfun = pfun||function(v){return v;};
                    ok = ok||{xxdisable:'no'};
                    no = no||{xxdisable:'yes'};

                    var val,res;
                    var tmp = [];
                    if(Ext.isArray(data)){
                        for (var i = 0; i < data.length; i++) {
                            val = pfun( Fn.string.format(by||'',data[i]) );
                            if(this.check(val)){  //是否有权限，无权限隐藏菜单按钮
                                res = this.check(val)? ok: no;   
                                tmp.push(Ext.apply(data[i],res||{}));
                            }
                        };
                    }
                    return tmp;
                },
                checkLogin:function(){

                    Fn.dom.click('page-erp-login',function(e,t,el){
                        var btnSign = t.getAttribute('_sign')||'';
                        if(btnSign==='download'){ window.open(Fn.url('Public/downloadClient')); }
                        else if(btnSign==='cancel'){ 
                            if( AppGui.win||false )AppGui.win.close();
                            else window.close(); 
                        }
                    },'input[_sign]');

                    Fn.dom.click('page-erp-login',function(e,t,el){
                        var r = el.select('input[name]').elements||[];
                        var data = {};
                        for (var i = 0; i < r.length; i++) {
                            if(r[i].name||fasle){
                                data[r[i].name] = r[i].value||'';
                            }
                        };
                        if((data.account || false) && (data.password||false)){
                            Fn.http.post(Fn.url('Public/checkLogin'),data,function(r){
                                if(r.success){
                                    Erp.getApplication().initApp(true);
                                }else{
                                    var loginMessage = Ext.select('div.loginMessage').elements;
                                    loginMessage[0].innerHTML = '请输入正确的用户名和密码';
                                }
                            });
                        }else alert('请输入正确的用户名和密码');
                        //
                    },'input[type=submit]');
                }
            };
    }
    </script>
</body>
</html>
